<template>
    <div id=app>
      <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="/">系统管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 卡片 -->
    <el-card class="box-card">
       <el-form :inline="true" :model="userVo">
         <el-row>
            <el-col :span="6">
              <el-form-item label="部门" label-width="70px">
            <el-select clearable v-model="userVo.departmentId" placeholder="请选择" >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                <span style="float: left">{{ item.label }}</span>
                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
              </el-option>
            </el-select>
          </el-form-item>
            </el-col>
            <el-col :span="6">
          <el-form-item label="用户名"  label-width="70px">
              <el-input clearable v-model="userVo.username" placeholder="请输入用户名查询"></el-input>
          </el-form-item>
            </el-col>
          <el-col :span="6">
              <el-form-item label="邮箱"  label-width="70px">
                <el-input clearable v-model="userVo.email" placeholder="请输入邮箱查询"></el-input>
              </el-form-item>
              </el-col>
            <el-col :span="6">
          <el-form-item label="性别"  label-width="70px">
            <el-radio-group  v-model="userVo.sex">
              <el-radio :label="0">男</el-radio>
              <el-radio :label="1">女</el-radio>
              <el-radio :label="null">全部</el-radio>
          </el-radio-group>
          </el-form-item>
            </el-col>
        </el-row>
      <el-row>
        <el-col :span="18">
          <el-form-item label="昵称"  label-width="70px">
            <el-input clearable v-model="userVo.nickname" placeholder="请输入昵称查询"></el-input>
          </el-form-item>
          <el-form-item style="margin-left:50px;">
            <el-button  icon="el-icon-refresh">重置</el-button>
            <el-button @click="search()" type="primary" icon="el-icon-search">查询</el-button>
            <el-button type="success" icon="el-icon-plus">添加</el-button>
            <el-button   icon="el-icon-download">导出</el-button>
          </el-form-item>
          </el-col>
        </el-row>
         
      </el-form>
            <!-- 表格 -->
        <el-table
        :data="userList"
        border
        max-height="400px"
        style="width: 100%;height: 390px">
        <el-table-column
          prop="id"
          label="#"
          width="50">
        </el-table-column>
        <el-table-column
          sortable
          prop="username"
          label="用户名"
          width="110">
        </el-table-column>
        <el-table-column
          sortable
          prop="sex"
          label="性别"
          width="60">
           <template slot-scope="scope">
          {{scope.row.sex==0?'男':(scope.row.sex==1?'女':'保密')}}
        </template>
        </el-table-column>
        <el-table-column
          sortable
          prop="departName"
          label="所属部门"
          width="180">
        </el-table-column>
        <el-table-column
          sortable
          prop="birth"
          label="生日"
          width="180">
        </el-table-column>
        <el-table-column
          sortable
          prop="email"
          label="邮箱"
          width="180">
        </el-table-column>
        <el-table-column
          sortable
          prop="phoneNumber"
          label="电话"
          width="100">
        </el-table-column>
        <el-table-column
          sortable
          prop="status"
          label="是否禁用"
          width="100">
          <template slot-scope="scope">
            <el-switch :v-model="scope.row.status==1"
            active-color="#13ce66"
            inactive-color="#ff4949">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column  label="操作">
          <el-button type="primary" size="mini" icon="el-icon-edit"></el-button>
          <el-button type="danger" size="mini" icon="el-icon-delete"></el-button>
          <el-button type="warning" size="mini" icon="el-icon-s-tools"></el-button>
        </el-table-column>
      </el-table>
      <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="current"
            :page-sizes="[5, 6, 7, 8]"
            :page-size="size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
          </el-pagination>
      </div> 
    </el-card>
        
    </div>
</template>

<script>
    import { request } from '../../request/index.js'
    export default { 
       methods: {
         search(){
           alert(111111)
            this.findUserInnerDepart();
         },
           handleSizeChange(val) {
        this.size=val;
        this.findUserInnerDepart()
      },
      handleCurrentChange(val) {
        this.current=val;
        this.findUserInnerDepart()
      },

      async findUserInnerDepart(){
        let result=await request({
          url:'/user/findUserInnerDepart',
          method:'post',
          params:{
              current:this.current,
              size:this.size,
          },
          data: this.userVo,
        })
        console.log(this.result)
        this.userList=result.data.userPage.records;
        this.total=result.data.userPage.total;
        
      },
    }, 
    created () {
      this.findUserInnerDepart();
    },
          data() {
        return {
          status:'',
            userVo:{
              departmentId:'',
              username:'',
              email:'',
              sex: 0,
              nickname:''
            },
           
          userList: [],
          options: [{
          value: '选项1',
          label: '黄金糕'
        }],
         //当前页码
            current:1,
        // 页码总条数
        total:0,
        //每页条数
        size:5,
        }
      }
    }
</script>

<style scoped>
    .el-breadcrumb{
        font-size: 14px;
    }
      .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
   .text {
    font-size: 14px;
  }

  .item {
    padding: 18px 0;
  }

  .box-card {
    width: 100%;
  }
</style>